package com.choosefine.it.base;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import com.choosefine.it.basedata.dao.CompanyInfoMapper;
import com.choosefine.it.basedata.dao.UserInfoMapper;
import com.choosefine.it.basedata.model.CompanyInfo;
import com.choosefine.it.basedata.model.UserInfo;
import com.choosefine.it.common.def.ResultCode;
import com.choosefine.it.common.exception.BusinessException;
import com.choosefine.it.common.utils.Assert;

/**
 * Service
 * 
 * @author guwenwei
 * 
 */
public class BaseService{
	
	@Value("#{yaml.get('service.shixiaobao.url')}")
	public String shixiaobaoURL=null;

	@Value("#{yaml.get('service.shopping.url')}")
	public String shoppingURL=null;

	@Value("#{yaml.get('service.console.url')}")
	public String consoleURL=null;

	@Value("#{yaml.get('service.usercent.url')}")
	public String usercentURL=null;

	@Value("#{yaml.get('service.push.url')}")
	public String pushURL=null;
	
	
	@Autowired
	private UserInfoMapper userinfomapper;
	
	@Autowired
	private CompanyInfoMapper companyinfomapper;
	
	/**
	 * userCode 个人用户校验
	 *  juchengyang 2017年3月13日
	 * @throws BusinessException 
	 */
	public void userInfoUserCodeCheck (String userCode) {
		UserInfo userinfo = userinfomapper.findByUserCode(userCode); 
		Assert.assertNotNull(userinfo, ResultCode.MSG_USERNOTEXIT);
	}
	
	/**
	 * 公司类型租户 UserCode 校验
	 *  juchengyang 2017年3月13日
	 */
	public void companyInfoUserCodeCheck (String userCode) {
		CompanyInfo companyInfo = companyinfomapper.findByUserCode(userCode);
		Assert.assertNotNull(companyInfo, ResultCode.MSG_USERNOTEXIT);
	}
}